package com.you.redis.string;

import com.you.redis.util.JedisUtils;
import redis.clients.jedis.Jedis;

/**
 * 测试redis string数据类型的操作
 */
public class RedisStringDemo {

    public static void main(String[] args) throws Exception {
        Jedis jedis = JedisUtils.getInstance().getJedis();
        //System.out.println(jedis.set("name", "tom1")); //直接设置值，覆盖原来的key的值
        //System.out.println(jedis.setnx("name1", "tom")); //不存在key，设置成功，存在，设置失败
        //System.out.println(jedis.setex("name2", 10, "tom2")); //设置key，并设置key的失效时间
        //System.out.println(jedis.set("name","tom","NX","EX",10)); //同时设置nx和ex,等同set name tom ex 10 nx
        System.out.println(jedis.incr("count")); //自增操作
    }

}
